package com.nbsaas.boot.ai.data.entity;

import com.nbsaas.boot.code.annotation.FormAnnotation;
import com.nbsaas.boot.code.annotation.FormField;
import com.nbsaas.boot.code.annotation.SearchItem;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.rest.filter.Operator;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;

import java.util.Date;

@Comment("AI对话会话")
@FormAnnotation(model = "AI对话会话")
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "nb_ai_session")
public class AiSession extends AbstractEntity {

    @Comment("会话标题")
    @FormField(title = "会话标题", placeholder = "请输入会话标题", grid = true)
    @Column(length = 100)
    private String title;

    @SearchItem(label = "会话标识", name = "sessionKey", operator = Operator.eq)
    @Comment("会话唯一标识")
    @FormField(title = "会话标识", placeholder = "系统生成", grid = true)
    @Column(length = 64, unique = true, nullable = false)
    private String sessionKey;

    @SearchItem(label = "关联用户ID", name = "userId", operator = Operator.eq)
    @Comment("关联用户ID")
    @FormField(title = "用户ID", grid = true)
    private Long userId;

    @Comment("关联应用ID")
    @FormField(title = "应用ID", grid = true)
    private Long appId;

    @Comment("消息数量")
    @FormField(title = "消息数量", grid = true)
    private Integer messageCount;

    @Comment("会话摘要")
    @FormField(title = "会话摘要", placeholder = "可选的摘要描述")
    @Column(length = 500)
    private String summary;

    @Comment("最后消息内容")
    @FormField(title = "最后消息", placeholder = "最后一条对话内容")
    @Column(length = 1000)
    private String lastMessage;

    @Comment("最后交互时间")
    @FormField(title = "最后交互时间", grid = true)
    private Date lastInteractTime;

    @Comment("是否归档")
    @FormField(title = "是否归档", grid = true)
    private Boolean archived;

    @Comment("排序权重")
    @FormField(title = "排序权重", grid = true)
    private Integer sortNum;

    @Comment("备注信息")
    @FormField(title = "备注", placeholder = "备注信息")
    private String note;
}


